# $Id: PKGBUILD 177072 2013-02-05 18:24:33Z eric $
# Maintainer:
# Contributor: Josh Taylor <joshtaylor.mail@gmail.com>
# Contributor: simo <simo@archlinux.org>
# Contributor: Douglas Soares de Andrade <douglas@archlinux.org>
# Contributor: Daniel J Griffiths <ghost1227@archlinux.us>

pkgbase=pyopengl
pkgname=('python2-opengl' 'python-opengl')
pkgver=3.0.2
pkgrel=2
pkgdesc="The cross platform Python binding to OpenGL and related APIs"
url="http://pyopengl.sourceforge.net/"
license=('BSD')
arch=('any')
makedepends=('freeglut' 'python2-distribute' 'python-distribute')
#source=("http://downloads.sourceforge.net/${pkgbase}/PyOpenGL-${pkgver}.tar.gz"
source=("http://pypi.python.org/packages/source/P/PyOpenGL/PyOpenGL-${pkgver}.tar.gz"
        'LICENSE')
md5sums=('77becc24ffc0a6b28030aa109ad7ff8b'
         '0b53c508a63e5dbaf44cdfb0fa103b3a')

build() {
  cp -r PyOpenGL-${pkgver} python-PyOpenGL-${pkgver}
}

package_python2-opengl() {
        depends=('freeglut' 'python2-distribute')
	conflicts=('python-pyopengl' 'python-opengl<=3.0.1-4')
	replaces=('python-pyopengl' 'python-opengl<=3.0.1-4')

        cd PyOpenGL-${pkgver}
	python2 setup.py install --root="${pkgdir}" --optimize=1
	install -Dm644 "${srcdir}/LICENSE" \
		"${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"

    # Fix the shebang
    sed -i 's|#!/usr/bin/env python|#!/usr/bin/python2|' \
      "${pkgdir}"/usr/lib/python2.7/site-packages/OpenGL/Tk/__init__.py
    sed -i 's|#! /usr/bin/env python|#!/usr/bin/python2|' \
      "${pkgdir}"/usr/lib/python2.7/site-packages/OpenGL/arrays/{_,}buffers.py
}

package_python-opengl() {
        depends=('freeglut' 'python-distribute')

        cd python-PyOpenGL-${pkgver}
	python setup.py install --root="${pkgdir}" --optimize=1
	install -Dm644 "${srcdir}/LICENSE" \
		"${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
